#!/usr/bin/env python
# encoding: utf-8
import requests

class MobSMS:
    #def __init__(self, appkey):
    def __init__(self):
        self.appkey = 'b565f5c32b84'
        #self.appkey = '97376c1c874e'
        #self.appkey = '5887b8134af8'
        self.verify_url = 'https://api.sms.mob.com/sms/verify'
    def verify_sms_code(self, zone, phone, code, debug=False):
        if debug:
            return 200
        data = {'appkey': self.appkey, 'phone': phone, 'zone': zone, 'code': code}
        print data
        req = requests.post(self.verify_url, data=data, verify=False)
        if req.status_code == 200:
            j = req.json()
            return j.get('status', 500)
        
        return 500

if __name__ == '__main__':
    mobsms = MobSMS('97376c1c874e')
    print mobsms.verify_sms_code(86, 18810314773, '4538')
